package com.tgy.基础学习.Lambda;

public class LambdaTest {

    /**
     * 2,静态内部类
     */
    static class Like2 implements iLike{
        @Override
        public void lambda() {
            System.out.println("i like lambda2  静态内部类");
        }
    }


    public static void main(String[] args) {
        //原始使用
        iLike like = new Like();
        like.lambda();
        like = new Like2();
        like.lambda();

        /**
         * 3,局部内部类
         */
        class Like3 implements iLike{
            @Override
            public void lambda() {
                System.out.println("i like lambda3  局部内部类");
            }
        }
        like = new Like3();
        like.lambda();

        /**
         * 4,匿名内部类
         * 没有类名，必须借助接口或者父类
         */
        like = new iLike(){
            @Override
            public void lambda() {
                System.out.println("i like lambda4  匿名内部类");
            }
        };
        like.lambda();

        /**
         * 5，lambda 简化
         */
        like = () ->{
            System.out.println("i like lambda5  Lambda!!!");
        };
        like.lambda();
    }
}


/**
 * 1，定义一个函数式接口
 */
interface iLike{
    //隐式声明抽象
    void lambda();
}

/**
 * 1，实现类
 */
class Like implements iLike{

    @Override
    public void lambda() {
        System.out.println("i like lambda1");
    }
}
